#ifndef __Snake_H
#define __Snake_H

#include "HardWare.h"
#include "stm32f1xx_hal.h"
#include <stdlib.h>
#include <list>


enum State
{
	Exit,
	Runing
};
enum SnakeDirection
{
	Up,
	Down,
	Left,
	Right,
	Null

};

struct Food
{
	uint8_t posx;
	uint8_t posy;
};

struct Snake_Node
{
	Snake_Node(uint8_t x = 0,uint8_t y = 0)
		:posx(x)
		,posy(y)
		,TailDriect(Right)
	{}

	uint8_t posx;
	uint8_t posy;
	SnakeDirection TailDriect;

};


class SnakeGame
{
public:	
	SnakeGame()
		:Snake{{18,1},{12,2},{6,2},{0,2}}
		,ShowHead (Snake_Head_Right)
		,state(Runing)
		,CurrentDirection(Right)
		
	{}
	
		
	State CheckGameOver();
	void Show_Snake();
	void CheckDir();
	void SnakeMove();
	void SnakeRun();
		
public:	
	void SetFood();



private:
	const uint8_t* ShowHead;
	std::list<Snake_Node> Snake;
	State state;
	SnakeDirection CurrentDirection;
	Food food;
};

#endif
